package com.ruimei.service.impl;

import com.ruimei.entitys.Parent;
import com.ruimei.entitys.RollBook;
import com.ruimei.entitys.Student;
import com.ruimei.entitys.StudentRoll;
import com.ruimei.mapper.RollBookMapper;
import com.ruimei.service.RollBookService;
import com.ruimei.util.ifUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class RollBookServiceImpl implements RollBookService {
    @Resource
    RollBookMapper mapper;


    @Override
    public Map<String, Object> addRollBook(RollBook rollBook) {
        String id = System.currentTimeMillis() + "";
        rollBook.setType("未点名");
        rollBook.setId(id);
        Integer i = mapper.addRollBook(rollBook);
        Map<String, Object> map =  ifUtil.YesOrNo(i);
        map.put("data",id);
        return map;
    }

    @Override
    public Map<String, Object> getRoll(RollBook rollBook) {
        Map<String, Object> map = new HashMap();
        List<RollBook> list = mapper.getRoll(rollBook);
        map.put("status", Boolean.valueOf(true));
        map.put("message", "查询成功");
        map.put("data", list);

        return map;
    }

    @Override
    public Map<String, Object> setRoll(RollBook rollBook) {
        rollBook.setType("已点名");
        Integer i = mapper.setRollBook(rollBook);
        Map<String, Object> map =  ifUtil.YesOrNo(i);
        map.put("data",rollBook.getId());
        return map;
    }

    @Override
    public Map<String, Object> getStuParent(String classId,String studentName) {
        Map<String, Object> map = new HashMap();
        List<StudentRoll> list = mapper.getStuParent(classId,studentName);
        map.put("status", Boolean.valueOf(true));
        map.put("message", "查询成功");
        map.put("data", list);
        return map;
    }
}
